from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.by import By

from pages.basepage import Basepage
from pages.mssages import MSG


class LogingPage(Basepage):
    #三个属性
    dl = (By.XPATH, '//a[@href="user.php"]')
    euname=(By.NAME,'username')
    pwd = (By.NAME,'password')
    anbut=(By.NAME,'submit')
    wdzh = (By.LINK_TEXT, '我的账户')
    wdly = (By.LINK_TEXT, '我的留言')
    zt = (By.NAME, 'msg_title')
    nr = (By.NAME, 'msg_content')
    wj = (By.NAME, 'message_img')
    tj = (By.XPATH, '//input[@type="submit" and @class="bnt_bonus"]')
    sc = (By.XPATH, '//*[@class="userCenterBox boxCenterList clearfix"]//a[1]')

    #行为
    def denglu(self, name='雨姐', mima='123456'):
        # 输入用户名
        self.findELe(self.euname).send_keys(name)
        # d.find_element(*self.euname).send_keys(name)
        # time.sleep(2)
        self.findELe(self.pwd).send_keys(mima)
        # d.find_element(*self.pwd).send_keys(mima)
        # time.sleep(2)
        self.findELe(self.anbut).click()
        # d.find_element(*self.anbut).click()
        # time.sleep(5)
    def logingok(self):
        t=self.getEleTxt(self.findELe(self.dl))
        return t

    def loginErrorNone(self):
        return self.getAlrettxt()
    def loginError(self):
        t=self.getEleTxt(self.findELe(self.dl))
        return t
#
#
# class MSG(LogingPage):
#     def liuyan(self, ZT='差评', NR='照骗', WJ=''):
#         # self.dlchlick(self.findELe(self.wdzh))
#         self.dlchlick(self.findELe(self.wdzh))
#         # d.find_element(*self.wdzh).click()
#         # time.sleep(2)
#         self.dlchlick(self.findELe(self.wdly))
#         # d.find_element(*self.wdly).click()
#         # time.sleep(2)
#         self.inputText(self.findELe(self.zt), ZT)
#         # d.find_element(*self.zt).send_keys(ZT)
#         # time.sleep(2)
#         self.inputText(self.findELe(self.nr), NR)
#         # d.find_element(*self.nr).send_keys(NR)
#         # time.sleep(2)
#         self.inputText(self.findELe(self.wj), WJ)
#         # d.find_element(*self.wj).send_keys(WJ)
#         # time.sleep(2)
#         self.dlchlick(self.findELe(self.tj))
#         # d.find_element(*self.tj).click()
#         # time.sleep(5)
#
#     def shanchu(self):
#         self.dlchlick(self.findELe(self.wdzh))
#         self.dlchlick(self.findELe(self.wdly))
#         self.dlchlick(self.findELe(self.sc))
#         tc = Alert(self.d)
#         tc.accept()

    # def logingok(self):
    #     t=self.getEleTxt(self.findELe(self.dl))
    #     return t
    #
    # def loginErrorNone(self):
    #     return self.getAlrettxt()
    # def loginError(self):
    #     t=self.getEleTxt(self.findELe(self.dl))
    #     return t

if __name__ == '__main__':
    DL=LogingPage()
    #正确
    DL.denglu("雨姐","123456")
    LY = MSG()
    LY.denglu('老蒯', '123456')
    # LY.liuyan('差评','实物与照片不符','')
    LY.shanchu()
    #错误
    # DL.denglu("雨姐","1234656")
    # #空
    # DL.denglu("","")


